From 4d5bf67dd1df3df21e087036dffe1dbd7b2d709b Mon Sep 17 00:00:00 2001 From: Keir Fraser Date: Mon, 3 Mar 2008 11:09:33 +0000 Subject: [PATCH] Fix xm vcpu-pin for inactive managed domains We cannot currently change cpu affinity definitions of inactive managed domains by xm vcpu-pin command. This patch enables changing cpu affinity definitions of inactive managed domains. However, we cannot change cpu affinity definitions to each vcpu because we cannot currently define cpu affinity definitions to each vcpu to domain configuration definitions. Therefore, we need to specify 'all' to VCPU argument of xm vcpu-pin command. Signed-off-by: Masaki Kanno --- tools/python/xen/xend/XendDomain.py | 24 +++++++++++++++++------- tools/python/xen/xend/XendDomainInfo.py | 6 ++++++ 2 files changed, 23 insertions(+), 7 deletions(-) diff --git a/tools/python/xen/xend/XendDomain.py b/tools/python/xen/xend/XendDomain.py index 0fcdbc3c1f..141942f3b9 100644 --- a/tools/python/xen/xend/XendDomain.py +++ b/tools/python/xen/xend/XendDomain.py @@ -1364,13 +1364,23 @@ class XendDomain: # set the same cpumask for all vcpus rc = 0 - for v in vcpus: - try: - rc = xc.vcpu_setaffinity(dominfo.getDomid(), int(v), cpumap) - except Exception, ex: - log.exception(ex) - raise XendError("Cannot pin vcpu: %s to cpu: %s - %s" % \ - (v, cpumap, str(ex))) + if dominfo._stateGet() in (DOM_STATE_RUNNING, DOM_STATE_PAUSED): + for v in vcpus: + try: + rc = xc.vcpu_setaffinity(dominfo.getDomid(), int(v), cpumap) + except Exception, ex: + log.exception(ex) + raise XendError("Cannot pin vcpu: %s to cpu: %s - %s" % \ + (v, cpumap, str(ex))) + else: + # FIXME: if we could define cpu affinity definitions to + # each vcpu, reprogram the following processing. + if str(vcpu).lower() != "all": + raise XendError("Must specify 'all' to VCPU " + "for inactive managed domains") + dominfo.setCpus(cpumap) + self.managed_config_save(dominfo) + return rc def domain_cpu_sedf_set(self, domid, period, slice_, latency, extratime, diff --git a/tools/python/xen/xend/XendDomainInfo.py b/tools/python/xen/xend/XendDomainInfo.py index 74a69fbc6d..471721eb23 100644 --- a/tools/python/xen/xend/XendDomainInfo.py +++ b/tools/python/xen/xend/XendDomainInfo.py @@ -1394,6 +1394,12 @@ class XendDomainInfo: def setResume(self, isresume): self._resume = isresume + def getCpus(self): + return self.info['cpus'] + + def setCpus(self, cpumap): + self.info['cpus'] = cpumap + def getCap(self): return self.info['vcpus_params']['cap'] -- 2.30.2